
import java.util.Arrays;

public class Insert {
    int[] arr={2,3,1,23,22};
    public static void main(String[] args) {
        Insert insert = new Insert();
        insert.Insert(insert.arr);
    }
    public void Insert(int[] arr){
        for (int i = 1; i < arr.length; i++) {
            int insert=arr[i];
            int insertIndex=i-1;
            while (insertIndex>=0&&arr[insertIndex]>insert){
                arr[insertIndex+1]=arr[insertIndex];
                insertIndex--;
            }
            arr[insertIndex]=insert;

            System.out.print(Arrays.toString(arr));
        }
    }
}
